<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/jsp/common/taglibs.jsp"%>

<!DOCTYPE html>
<html>
<head>
<title>security system</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link rel="stylesheet"
	href="<c:url value="/css/bootstrap.min.css"></c:url>">

</head>
<body>



	<nav class="navbar navbar-inverse" role="navigation">
		<!-- Brand and toggle get grouped for better mobile display -->
		<div class="navbar-header" style="margin:10px;">
			<button type="button" class="navbar-toggle" data-toggle="collapse"
				data-target="#bs-example-navbar-collapse-1">
				<span class="sr-only">Toggle navigation</span> <span
					class="icon-bar"></span> <span class="icon-bar"></span> <span
					class="icon-bar"></span>
			</button>
			<a class="navbar-brand" href="#">UUC Bioengineering Ltd.</a>
		</div>

		<!-- Collect the nav links, forms, and other content for toggling -->
		<div class="collapse navbar-collapse"
			id="bs-example-navbar-collapse-1" style="margin:10px;">

			<ul class="nav navbar-nav navbar-right" style="margin-right:20px;">
				<li><a href="#">${loginedAdmin.admin_ID}</a>
				</li>
				<li><a href="#">${loginedAdmin.admin_Username}</a>
				</li>
				<li><a href="#">Senior Administrator</a>
				</li>
				<li><a
					href='<s:url namespace="/system" action="adminLogout"></s:url>'>Log
						out</a>
				</li>
			</ul>
		</div>
		<!-- /.navbar-collapse -->
	</nav>
	<div class="row">
		<ol class="breadcrumb" style="padding-left:50px;padding-right:50px;">
			<li><a
				href='<s:url namespace="/senioradmin" action="homeAction"/>'>Home</a>
			</li>
			<li><a
				href='<s:url namespace="/senioradmin" action="loadAction"/>'>View
					User</a>
			</li>
		</ol>
	</div>
	<div class="container">
		<div id="qryarea">
			<s:form action="loadAction" method="post" namespace="/senioradmin">
				<div class="row-fluid">
					<div class="span10">
						UserID ：
						<s:textfield name="helper.userID"
							cssStyle="margin-top:5px;height:30px;width:150px;"></s:textfield>
						UserName ：
						<s:textfield name="helper.userName" cssClass="btn-large"
							cssStyle="margin-top:5px;height:30px;width:150px;"></s:textfield>
						Access :
						<s:select name="helper.accessID" headerKey=""
							headerValue="===Choose==="
							list="#{'1':'Area 1','2':'Area 2','3':'Area 3','4':'Area 4'}"></s:select>
						<s:submit value=" Query " style="margin: 5px 0px 15px 10px;"
							cssClass="btn btn-success"></s:submit>
					</div>
				</div>
			</s:form>
		</div>
		<div class="row">
			<table class="table table-hover">
				<thead>
					<tr>
						<th>UserID</th>
						<th>UserName</th>
						<th>Title</th>
						<th>Access</th>
						<th>ExpireDate</th>
						<th>Status</th>
						<th>Operation</th>
					</tr>
				</thead>
				<tbody>
					<s:iterator value="page.pageContent">
						<tr>
							<td><s:property value="user_ID" />
							</td>
							<td><s:property value="user_Name" />
							</td>
							<td><s:property value="title" />
							</td>
							<td><s:if test="access_ID==\"1\"">Area clearance 1</s:if> <s:elseif
									test="access_ID==\"2\"">Area clearance 2</s:elseif> <s:elseif
									test="access_ID==\"3\"">Area clearance 3</s:elseif> <s:elseif
									test="access_ID==\"4\"">Area clearance 4</s:elseif> <s:else>Invalid</s:else>
							</td>
							<td><s:property value="expire_Date" />
							</td>
							<td><s:if test="status==\"1\"">Active</s:if> <s:else>Inactive</s:else>
							</td>
							<td>
								<div class="col-sm-offset-1 col-sm-2">
									<button type="submit" class="btn btn-primary"
										onclick="updateUser('<s:property value="user_ID" />');">Modify</button>
								</div>
								<div class="col-sm-offset-1 col-sm-2">
									<button type="submit" class="btn btn-primary"
										title="Delete User <s:property value="user_ID" />"
										onclick="removeUser('<s:property value="user_ID" />');">Delete</button>
								</div>
							</td>
							<td><br> <br></td>
						</tr>
					</s:iterator>
				</tbody>
			</table>
		</div>
		<div id="pageinfo">
			Total
			<s:property value="page.totalRecNum" />
			Records, Current View
			<s:property value="page.startIndex" />
			-
			<s:property value="page.endIndex" />
			,
			<s:property value="page.pageNo" />
			/
			<s:property value="page.totalPageNum" />
			Page |
			<s:if test="page.pageNo>1">
				<span class="linkspan" onclick="doQuery(1)">First</span>&nbsp;
	           </s:if>
			<s:if test="page.prePage">
				<span class="linkspan"
					onclick="doQuery(<s:property value="page.pageNo-1"/>)">Previous</span>&nbsp;
	           </s:if>
			<s:if test="page.nextPage">
				<span class="linkspan"
					onclick="doQuery(<s:property value="page.pageNo+1"/>)">Next</span>&nbsp;
	           </s:if>
			<s:if test="page.pageNo!=page.totalPageNum">
				<span class="linkspan"
					onclick="doQuery(<s:property value="page.totalPageNum"/>)">Last</span>&nbsp;
	           </s:if>
			| <input type="text" id="appendedInputButton" class="span1"
				onkeypress="onlynumber();">
			<button class="btn"
				onclick="doQuery($('#appendedInputButton').val());">Go</button>

		</div>
	</div>
	<script src="<c:url value="/js/jquery-1.9.1.min.js"></c:url>"></script>
	<script src="<c:url value="/js/bootstrap.min.js"></c:url>"></script>
	<script type="text/javascript">

	function removeUser(userid){
		if(confirm("Are you sure to delete user "+userid+" ?")){
			location.href='<s:url namespace="/senioradmin" action="remove"/>?user.user_ID='+userid;
		}
	}
	function doQuery(pageno){
		if(pageno<1 || pageno><s:property value="page.totalPageNum"/>){
			alert("Valid page from: 1-<s:property value="page.totalPageNum"/>");
			$('appendedInputButton').select();
              return;
		}
		var f=document.forms[0];
            f.action=f.action+"?page.pageNo="+pageno;
            f.submit();
	}
	function updateUser(userid){
		location.href='<s:url namespace="/senioradmin" action="forUpdateUser"/>?user.user_ID='+userid;
	};
	
</script>
</body>
</html>